# defs.bzl
weathers = ["sunny", "cloudy", "rainy", "snowy"]

def _weather_impl(ctx):
    weather = ctx.build_setting_value    
    if weather not in weathers:
        fail("weather was set to unallowed value " + weather)
    print("It's {0} today!".format(weather))

weather_flag = rule(
    implementation = _weather_impl,
    build_setting = config.string(flag = True),
)